package com.heyun.controller;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;


import com.heyun.bean.HeyunServiceFAQ;
import com.heyun.service.impl.HeyunServiceFAQImpl;

@Controller
@RequestMapping("/heyunServiceFAQ")
public class HeyunServiceFAQController {
	@Autowired
	private HeyunServiceFAQImpl heyunServiceFAQImpl;
  //初到本页面时为需要默认查询形成表格，命名为selectForShowTable（暂不考虑依条件查询），应当考虑分页了
	@ResponseBody
	@RequestMapping("/select")
	public Map listHeyunServiceFAQ(HeyunServiceFAQ heyunServiceFAQ,int currentPage){
		System.out.println("testselectForShowTable"); 
		Map map=heyunServiceFAQImpl.listHeyunServiceFAQ(heyunServiceFAQ,currentPage);
		return map;
	}
	//按条件查询的那个先放一放，尽力合并到第一项上
	//******(此处省略一万行代码![>.<]!)
	//到添加了，命名为insert,往后依旧
	@ResponseBody
	@RequestMapping("/insert")
	public int insertHeyunServiceFAQ(HeyunServiceFAQ heyunServiceFAQ){
		Date date=new Date();
		String lastOperateTime=new SimpleDateFormat("yyyy-MM-dd hh:mm:ss").format(date);
		heyunServiceFAQ.setLastOperateTime(lastOperateTime);
		System.out.println("testinsert");
		int a=heyunServiceFAQImpl.insertHeyunServiceFAQ(heyunServiceFAQ);
		return a;
	}
	//此处为修改需要事先做展示最为恰当，那样就需要前台ajax来后台异步查询一下
	@ResponseBody
	@RequestMapping("/update")
	public int updateHeyunServiceFAQ(HeyunServiceFAQ heyunServiceFAQ){
		int a=heyunServiceFAQImpl.updateHeyunServiceFAQ(heyunServiceFAQ);
		return a;
	}
	//此处为删除，或涉及批量删除
	@ResponseBody
	@RequestMapping("/delete")
	public int deleteHeyunServiceFAQ(HeyunServiceFAQ heyunServiceFAQ){
		System.out.println("testdelete");
		int a =heyunServiceFAQImpl.deleteHeyunServiceFAQ(heyunServiceFAQ);
		return a;
	}
	//查看，一定是单个查看，故而要传入其id以为依据,但是我要放一个对象进去，形式上更统一一点
	@ResponseBody
	@RequestMapping("/selectExtra")
	public HeyunServiceFAQ getHeyunServiceFAQExtra(HeyunServiceFAQ heyunServiceFAQ){
		System.out.println("/selectExtra");
		HeyunServiceFAQ heyunServiceFAQResult=heyunServiceFAQImpl.getHeyunServiceFAQExtra(heyunServiceFAQ);
		System.out.println(heyunServiceFAQResult);
		return heyunServiceFAQResult;
	}
}
